﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SmartSpace.OA;
using SmartSpace.Web;

namespace SmartSpace.WebApp.Modules.OA.Pages
{
    public partial class DocFolder_Edit : SsTemplatePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindFolderName();
            }
        }

        public void BindFolderName()
        {
            string pid = Request.QueryString["parentId"] ?? string.Empty;
            OAService server = new OAService();
            DocItem doc = server.GetDocItem(new Guid(pid));
            this.txt_FolderName.Text = doc.Caption;
            this.txt_FolderId.Text = pid;
        }

        protected void btn_Save_Click(object sender, EventArgs e)
        {
            string pid = Request.QueryString["parentId"] ?? string.Empty;
            OAService server = new OAService();
            DocItem doc = server.GetDocItem(new Guid(pid));
            doc.Caption = this.txt_FolderName.Text;

            ServiceResult result = server.SaveDocItem(doc);
            if (result.IsSuccess)
            {
                Response.Redirect("DocItem-List.aspx");
            }
        }
    }
}